# @scriptmeta-start
# @version: 0.9.8.11
# @summary: checks if there are upcoming holidays ( United States ) in the next @param(daysAhead)
# @type: device_script
# @author: kishore reddy
# @arg: name: daysAhead,   alias: days,     type: number,  default: n/a,     required: yes, examples: 8 | 5
# @arg: name: displayMode, alias: display,  type: text,    default: 'table', required: no,  examples: 'table' | 'list'
# @license: http://www.codehelixsolutions.com
# @script-version: 1.0
# @fluentscript-version: ${fs-version}
# @tags: birthdays, alert, friends
# @isInstalled: true
# @scriptmeta-end

set holidays =  [ 
					name                        |  holidaydate                  |   type 
					'new years day'             ,  january 1                	,   :federal        
					'martin luther king day'    ,  3rd monday in january    	,   :federal         
					'washingtons birthday'      ,  3rd monday in february   	,   :federal         
					'memorial day'              ,  last monday in may       	,   :federal         
					'independence day'          ,  july 4                   	,   :federal        
					'labor day'                 ,  1st monday in september  	,   :federal         
					'columbus day'              ,  2nd monday in october    	,   :federal         
					'veterans day'              ,  4th thursday in november 	,   :federal        
					'thanksgiving day'          ,  november 28              	,   :federal         
					'christmas day'             ,  december 25              	,   :federal     
				]

upcoming = list of ( holidayname, date )

# go through each contact and see if their birthday is coming up in the next x days.
with each holiday
{   
    if holidaydate equals today + days(daysAhead)
    {       
        upcomingHolidays.add name, holidaydate, ' No work! ' 
    }
}

return { success: any upcoming ?, data: holidays, type: 'table' display: 'table' }

